#!/usr/bin/env python
# coding=utf-8
'''
# @Created on : 2016/04/17 11:41
# @Author     : ldf (ldf@eehello.com)
# @Link       : http://www.eehello.com
# @Version    : 
# 本程序在python2.7下测试通过
'''

import pickle
import datetime

def run(shoping=0,kahao,mima):
    with open('backgroud/kami.cfg', 'rb') as ff:
        kami = pickle.load(ff)
    cuowu = 1
    for i in kami:
        if kahao == i[0] and mima == i[1]:
            cuowu = 0
    if cuowu:
        print('您输入的账号密码有误')
        break

    with open('backgroud/ka_mon', 'rb') as ff:
        ka_mons = pickle.load(ff)
    money = ka_mons[str(kahao)]
    if money >= shoping:
        money -= shoping
        ka_mons[str(kahao)] = money
        with open('backgroud/ka_mon', 'wb') as ff:
            pickle.dump(ka_mons, ff)
        nowtime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        with open('backgroud/jiaoyi_list', 'ab') as ff:
            data = nowtime + '消费' + money
            datalist[kahao].append(data)
    else:
        print('对不起，您的余额不足！')
        break


